Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Problem with SetRenderDCOffset
  FAQ FAQ  Forum Search   Register Register  Login Login

Problem with SetRenderDCOffset

 Post Reply Post Reply
Author
Message
siggeltheturtle View Drop Down
Beginner
Beginner


Joined: 19 Dec 13
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote siggeltheturtle Quote  Post ReplyReply Direct Link To This Post Topic: Problem with SetRenderDCOffset
    Posted: 20 Dec 13 at 12:13PM
Hi all,

my goal is to send a pdf to a defined printer with defined settings like tray, dpi etc. One important functionality is to shift the pdf to a defined offset position in order to align it precisely for different printers.

I tried some C++ example code and everything works fine - except for the offset having no impact at all. What I did (after unlocking the library and leaving out error handling here, except for the offset the code successfully printed out the given pdf):

QP.LoadFromFile(L"my.pdf", L""));
CustomPrinter = QP.NewCustomPrinter(L"Printername");
QP.SetupCustomPrinter(CustomPrinter, 5, 720) // dpi
...
iPrintOptions = QP.PrintOptions(0,0, L"Printing Sample");
QP.SetRenderDCOffset(50,100); // offset
QP.PrintDocument(CustomPrinter, 1, 1, iPrintOptions);


I tried the offset line at different places, but it had no impact. Am I using it in a wrong way? Or is there a completely different way for shifting the incoming pdf before printing it out?

Thanks in advance for your help,
siggeltheturtle
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 29 Dec 13 at 2:19AM
Siggel,

The QP.SetRenderDCOffset function is only designed to work with the RenderPageToDC function.

One option may be to adjust the MediaBox/CropBox values to offset the whole page in order to simulate the setting of a printer margin.

Andrew.


Back to Top
siggeltheturtle View Drop Down
Beginner
Beginner


Joined: 19 Dec 13
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote siggeltheturtle Quote  Post ReplyReply Direct Link To This Post Posted: 13 Jan 14 at 9:16PM
My full solution: when only modifying the crop box, I only was able to shift to the outside, but not into the page. I tried different combinations and finally ended up modifying all boxes in the same way to get the desired behavior.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jan 14 at 11:08AM
Siggel,

Another option is to add a transformation matrix to the start to the PDF page to give it an offset.

            QP.LoadFromFile("myPDFfile.pdf", "");
            QP.NormalizePage(0);
            int c = QP.NewContentStream();

            string s = "1.05 0 0 0.5 20 200 cm ";   // ScaleX = 1.05, ScaleY = 0.5, XOffset = 20 points, YOffset = 200 points (from bottom)

            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            Byte[] bytes = encoding.GetBytes(s);

            QP.SetContentStreamFromString(bytes);
            QP.MoveContentStream(c, 1);

            QP.SaveToFile("out.pdf");

You can always delete the added content stream after printing to restore the PDF page to its original state.

Back to Top
JeffLebowski View Drop Down
Beginner
Beginner


Joined: 29 Sep 15
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote JeffLebowski Quote  Post ReplyReply Direct Link To This Post Posted: 29 Sep 15 at 9:09AM
Hi,

I needed exactly the same thing and I used AndrewC's code (but in VBScript).
It works but only applies the offset to the first page. The other pages in the PDF remain without offset.

I'm not that experienced with the quickpdf functions. Is there an easy way to add the offsetstream to each page?
Back to Top
JeffLebowski View Drop Down
Beginner
Beginner


Joined: 29 Sep 15
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote JeffLebowski Quote  Post ReplyReply Direct Link To This Post Posted: 29 Sep 15 at 9:13AM
Nevermind, it was my mistake. Got it to work :)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store