Product: PDFNetC
Product Version: 10.1.0
Please give a brief summary of your issue:
Error and segfault when converting .docx file containing a date picker with OfficeToPDF
.
tmp/testing.rb:10:in `OfficeToPDF': PDFNet Exception: document layout failed: std::bad_alloc (StandardError)
from tmp/testing.rb:10:in `<main>'
I’ve also noticed segfaults but only on x86_64 platforms. Only std::bad_alloc
was observed in arm64.
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
Create a new .docx file with Microsoft Word on macOS (v16.73). Create a date picker control with VB:
- Click inside document where you want to place the date picker
- In the “Developer” tab, click “Visual Basic”
- Define subroutine
Sub AddDatePicker() Dim cc As ContentControl Dim dt As Date Set cc = ActiveDocument.ContentControls _ .Add(wdContentControlDate) dt = Date cc.Range.Text = dt End Sub
- Run the sub and close the VB editor
- Observe date picker is inserted in the document
- Save
The script:
# frozen_string_literal: true
require '/usr/local/PDFNetC/Lib/PDFNetRuby'
PDFNetRuby::PDFNet.Initialize(ENV.fetch('PDFTRON_LICENSE_KEY'))
filepath = ARGV.first
doc = PDFNetRuby::PDFDoc.new
doc.Lock
PDFNetRuby::Convert.OfficeToPDF(doc, filepath, nil)
doc.Unlock
Run:
ruby tmp/testing.rb tmp/datepicker.docx
Output:
PDFNet is running in demo mode.
Package: base
Package: office
tmp/testing.rb:10:in `OfficeToPDF': PDFNet Exception: document layout failed: std::bad_alloc (StandardError)
from tmp/testing.rb:10:in `<main>'
If I add additional text after the date picker, the script segfaults on x86_64. For instance, in the doc:
6/21/23
This is a test.
The “6/21/23” is from the date picker. The “This is a test.” text was typed in by hand. The segfault is accompanied by the control frame info, Ruby level backtrace info, machine register context, C level backtrace info, Other runtime info, and process memory map. Added latest in a reply comment.
Please provide a link to a minimal sample where the issue is reproducible:
See above.