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!
Problem with SetRenderDCOffset |
Post Reply |
Author | |
siggeltheturtle
Beginner Joined: 19 Dec 13 Status: Offline Points: 5 |
Post Options
Thanks(0)
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 |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Siggel, 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. |
|
siggeltheturtle
Beginner Joined: 19 Dec 13 Status: Offline Points: 5 |
Post Options
Thanks(0)
|
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.
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
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. |
|
JeffLebowski
Beginner Joined: 29 Sep 15 Status: Offline Points: 2 |
Post Options
Thanks(0)
|
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?
|
|
JeffLebowski
Beginner Joined: 29 Sep 15 Status: Offline Points: 2 |
Post Options
Thanks(0)
|
Nevermind, it was my mistake. Got it to work :)
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store