Rank: Member
Groups: Registered
Joined: 10/19/2017(UTC) Posts: 14  Location: North Carolina Was thanked: 1 time(s) in 1 post(s)
|
Hello,
I am seeing something that I am having trouble understanding. Our program has a number of pdf's that we store as zipped packages on the file system. We have a (fairly) simple procedure whereby we pick up one of these zip files, extract the required pdf, put it into a PdfPrintDocument, then print it out. We are using PrintSizeMode.ActualSize which should, by my understanding, render the document "true" to the original pdf without any scaling, shifting, etc.
To see if things line up, I am printing the document through two different methods. Firstly, I will manually extract the document from the zip file outside of the program and print it with Adobe Acrobat. I am certain to choose actual size in my print settings so as not to have any scaling or other issues relating to this. I then go into our program and print the same document using PdfPrintDocument with PrintSizeMode.ActualSize. I am consistently seeing that every document printed from the program is shifted 4mm towards the right side of the page and 4mm towards the bottom of the page.
I initially thought that this might be some sort of margin issue, but I do not see any sort of margin api's in the SDK. The only other thing I know of that might cause some sort of margin effect might be MediaBox, CropBox or ArtBox. The majority of the documents that we deal with are 8.5 x 11 US letter format, and the various "Box" settings all seem to follow the basic format:
bottom: 0 left: 0 right: 612 top: 792
which, if I presume a standard presentation format of 72 dpi, calculates to a box which is 8.5 x 11 anchored at the origin (which for a pdf is the bottom left of the page). In effect then, my various "Boxes" should all cover the entire page and I would think that they shouldn't cause the shifting issues that I am seeing.
As a point of note, I am not seeing any scaling issues, only this consistent shift to the right and down by 4mm.
Is there another piece of this puzzle that I am missing that might be causing this?
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 10/19/2017(UTC) Posts: 14  Location: North Carolina Was thanked: 1 time(s) in 1 post(s)
|
In order to further diagnose this, I created a barebones app. Code:using System.Linq;
using System.Windows.Forms;
namespace DocPrint
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
PdfCommon.Initialize("");
}
private void BtnSelect_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog
{
AutoUpgradeEnabled = true,
CheckFileExists = true,
CheckPathExists = true,
Multiselect = false,
ReadOnlyChecked = true,
ShowHelp = false,
ShowReadOnly = false,
SupportMultiDottedExtensions = false,
Title = "Please choose a file to print."
})
{
DialogResult dr = ofd.ShowDialog();
if ((dr == DialogResult.OK) || (dr == DialogResult.Yes))
{
using (MemoryStream ms = new MemoryStream())
{
using (ZipFile zip = ZipFile.Read(ofd.FileName))
{
zip.Entries.First().ExtractWithPassword(ms, "<password>");
}
PdfDocument doc = PdfDocument.Load(ms);
doc.Save("output.pdf", Patagames.Pdf.Enums.SaveFlags.NoIncremental);
PdfPrintDocument printDoc = new PdfPrintDocument(doc);
printDoc.PrintSizeMode = PrintSizeMode.ActualSize;
printDoc.Print();
}
}
}
}
}
}
I opened the saved output.pdf and printed it with Acrobat. Compare that to the result from printDoc.Print() and again, I have the same shift between the two of 4mm.
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 10/19/2017(UTC) Posts: 14  Location: North Carolina Was thanked: 1 time(s) in 1 post(s)
|
Okay, it appears that what I was missing was AutoCenter. Once I set that, things seem to be coming out fine now.
Thanks
|
 1 user thanked lxman for this useful post.
|
|
|
|
Forum Jump
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.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close