Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi, I've got still the problem with printing/saveing forms with patagames. The arrow of comboboxes are printed/saved with the pdf. Also when the value in a text field is too long, the + are printed/saved. Please have a look to the attachments. DocAcrobat was printed/saved with Acrobat. DocPata was printed/saved with Patagames. DocPata was printed/saved with Patagames with a workaround With the workaround, the arrows aren't showed but the text was truncated. Hope you can help. I've got much responses of our customers and I don't want look to a other pdf tool. Regards Peter  DocAcrobat.pdf (36kb) downloaded 9 time(s). DocPata.pdf (55kb) downloaded 10 time(s). DocPataWorkaround.pdf (58kb) downloaded 10 time(s).
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi, sorry, I've forgot the workaround Code:
foreach (PdfField field in pdfViewer1.FillForms.InterForm.Fields)
{
if (field.Type == FormFieldTypesEx.ComboBox)
{
if (field.Dictionary.ContainsKey("AP"))
{
var apStream = field.Dictionary["AP"].As<PdfTypeDictionary>()["N"].As<PdfTypeStream>();
string src = System.Text.Encoding.GetEncoding(1252).GetString(apStream.DecodedData);
int s = src.LastIndexOf("ET", StringComparison.Ordinal);
if (s > 0)
{
string substr = src.Substring(0, s + 2);
var newData = System.Text.Encoding.GetEncoding(1252).GetBytes(substr);
apStream.Init(newData);
}
}
}
}
Import: I have to use LastIndexOf instead IndexOf, because the comboBox can have a value with "ET". Second: when there are tow combobox fields with the same name in the pdf, the field hasn't got the Dictionary "AP". Regards Peter Edited by moderator Monday, April 16, 2018 5:14:41 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi, sorry, but I can't distribute our apps with this mistake. It's a pitty, but printing documents with arrows of comboboxes is not ok. Workaround is working, but I need the whole width for the text. Spend so much time in this great tool ...
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,113
Thanks: 8 times Was thanked: 130 time(s) in 127 post(s)
|
Could you please provide source document? Maybe the workaround needs a little fix.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi, here it is.
Regards Peter
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Sorry, now with attachment  AntragS4.pdf (122kb) downloaded 8 time(s).
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,113
Thanks: 8 times Was thanked: 130 time(s) in 127 post(s)
|
Looks like following may help Code:
public void PrintDoc()
{
//removes all arrows from comboboxes. (all that lies after text object enclosed by BT ... ET tag in the stream)
//BT - begin text, ET - end text
foreach (var ctrl in pdfViewer1.FillForms.InterForm.Controls)
{
if (ctrl.Type == FormFieldTypesEx.ComboBox)
{
var apStream = ctrl.Dictionary["AP"].As<PdfTypeDictionary>()["N"].As<PdfTypeStream>();
string src = apStream.DecodedText ?? "";
int s = src.IndexOf("BT");
if (s > 0)
{
int e = src.IndexOf("ET");
if (e > s)
{
string substr = "q " + src.Substring(s, e - s + 2) + " Q";
var newdata = PdfCommon.DefaultAnsiEncoding.GetBytes(substr);
if (apStream.Dictionary.ContainsKey("Filter"))
apStream.Dictionary.Remove("Filter");
apStream.Init(newdata);
}
}
}
}
pdfViewer1.Document.Pages[0].Dispose();
pdfViewer1.Invalidate();
//Show standard print dialog
var printDoc = new PdfPrintDocument(pdfViewer1.Document);
var dlg = new PrintDialog();
dlg.AllowCurrentPage = true;
dlg.AllowSomePages = true;
dlg.UseEXDialog = true;
dlg.Document = printDoc;
this.BeginInvoke(new Action(() =>
{
if (dlg.ShowDialog() == DialogResult.OK)
{
PrintController printController = new StandardPrintController();
printDoc.PrintController = printController;
printDoc.Print();
}
}));
}
The idea is remove all unwanted content including clipping area. Only a text object should remain. "q BT ... ET Q" So before workaround and after one  Edited by user Wednesday, April 25, 2018 5:24:49 AM(UTC)
| Reason: fix the code: 1. Uses controls instead of fields; 2. Problems with encoding; 3. Page invalidation; 4
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi Paul, thanks for the quick answer and your time! With your code nothing will be print in these fields. Attachted the debug values of srv und substr. Perhaps you see what's wrong. Regards Peter  debug1.JPG (19kb) downloaded 9 time(s).
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,113
Thanks: 8 times Was thanked: 130 time(s) in 127 post(s)
|
The "Filter" entry should be removed before init stream. Code:
if(apStream.Dictionary.ContainsKey("Filter"))
apStream.Dictionary.Remove("Filter");
apStream.Init(newdata);
I have modified the code in the previous topic. Some other problems was also fixed (please see the reason of changes) Edited by user Monday, April 23, 2018 10:01:16 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi Paul, thanks, yes this is working but not in the attachment file. There are two comboboxes which have the same name. I think there is not a "AP" key. Can you help me again?  S34.pdf (123kb) downloaded 8 time(s).
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,113
Thanks: 8 times Was thanked: 130 time(s) in 127 post(s)
|
I did a little research and found out that it's necessary to use Controls instead of Fields. I changed the code in the previous topic. Use it instead.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 10/13/2017(UTC) Posts: 51  Location: Freiburg Thanks: 3 times
|
Hi Paul, many thanks! This seems working! Sorry for my troubsome! But at the moment that's very important for the app!
Regards Peter
|
|
|
|
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